package com.winxuan.channel.service.member.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.winxuan.channel.model.member.User;
import com.winxuan.channel.service.member.UserService;
import com.winxuan.support.dao.BaseDao;

@Service("userService")
public class UserServiceImpl implements UserService,UserDetailsService {
	
	private BaseDao baseDao;

	@Override
	public User get(Integer id) {
		User user = (User) baseDao.get(User.class, id);
		return user;
	}

	@Override
	public User findUserByUserName(String username) {
		return (User)baseDao.getByProperty(User.class, "username", username);
	}

	@Override
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException {
		User user = findUserByUserName(username);
		return user;
	}

	public void setBaseDao(BaseDao baseDao) {
		this.baseDao = baseDao;
	}
	
}
